import { defineStore } from 'pinia'

export const useDocRepRequestData = defineStore('requestDataForm', () => {
    const requestData = ref({})
    const count_nar_done_lgot = ref(0)
    const count_nar_done_pd = ref(0)
    const count_nar_open_lgot = ref(0)
    const count_nar_open_pd = ref(0)
    const doc_finish_nar_lgot = ref([])
    const doc_finish_nar_lgot_sum = ref(0)
    const doc_finish_nar_pd = ref([])
    const doc_finish_nar_pd_sum = ref(0)
    const naryad_input = ref({})
    const nar_number_input = ref('')
    const doc_finish_nar_usl_lgot = ref([])
    const doc_finish_nar_usl_pd = ref([])
    const doc_pdr_nar_lgot = ref([])
    const doc_pdr_nar_lgot_sum = ref(0)
    const doc_pdr_nar_pd = ref([])
    const doc_pdr_nar_pd_sum = ref(0)

    const doc_pdr_nar_usl_pd = ref([])
    const doc_pdr_nar_usl_lgot = ref([])

    function setRequestData(dict) {
        requestData.value = dict
        count_nar_done_lgot.value = dict.count_nar_done_lgot
        count_nar_done_pd.value = dict.count_nar_done_pd
        count_nar_open_lgot.value = dict.count_nar_open_lgot
        count_nar_open_pd.value = dict.count_nar_open_pd
        doc_finish_nar_lgot.value = dict.doc_finish_nar_lgot
        doc_finish_nar_lgot_sum.value = dict.doc_finish_nar_lgot_sum
        doc_finish_nar_pd.value = dict.doc_finish_nar_pd
        doc_finish_nar_pd_sum.value = dict.doc_finish_nar_pd_sum
        doc_pdr_nar_lgot.value = dict.doc_pdr_nar_lgot
        doc_pdr_nar_lgot_sum.value = dict.doc_pdr_nar_lgot_sum
        doc_pdr_nar_pd.value = dict.doc_pdr_nar_pd
        doc_pdr_nar_pd_sum.value = dict.doc_pdr_nar_pd_sum
    }
    function setNaryad(naryad) {
        naryad_input.value = naryad
    }
    function setNarUsl(dict_resp) {
        doc_finish_nar_usl_lgot.value = dict_resp.doc_finish_nar_usl_lgot
        doc_finish_nar_usl_pd.value = dict_resp.doc_finish_nar_usl_pd
        doc_finish_nar_lgot_sum.value += dict_resp.sum_lgot
        doc_finish_nar_pd_sum.value += dict_resp.sum_pd
        count_nar_done_lgot.value += dict_resp.count_finish_nar_usl_lgot
        count_nar_done_pd.value += dict_resp.count_finish_nar_usl_pd
        doc_pdr_nar_usl_lgot.value = dict_resp.doc_pdr_nar_usl_lgot
        doc_pdr_nar_usl_pd.value = dict_resp.doc_pdr_nar_usl_pd
        doc_pdr_nar_lgot_sum.value += dict_resp.pdr_sum_lgot
        doc_pdr_nar_pd_sum.value += dict_resp.pdr_sum_pd

    }
    return { requestData, setRequestData, setNaryad, setNarUsl, doc_finish_nar_usl_lgot, doc_finish_nar_usl_pd, naryad_input, nar_number_input, count_nar_done_lgot, count_nar_done_pd, count_nar_open_lgot, count_nar_open_pd, doc_finish_nar_lgot, doc_finish_nar_lgot_sum, doc_finish_nar_pd, doc_finish_nar_pd_sum, doc_pdr_nar_lgot, doc_pdr_nar_lgot_sum, doc_pdr_nar_pd, doc_pdr_nar_pd_sum, doc_pdr_nar_usl_lgot, doc_pdr_nar_usl_pd}
})